package com.chain.qs.modules.biz.service;

import com.chain.qs.common.service.CrudService;
import com.chain.qs.modules.biz.dao.StationGroupCfgExtendDao;
import com.chain.qs.modules.biz.entity.StationGroupCfgExtend;
import com.google.common.collect.Maps;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * 设备Service
 *
 * @author wangzhiping
 */
@Service
//@Transactional(readOnly = true)
public class StationGroupCfgExtendService extends CrudService<StationGroupCfgExtendDao, StationGroupCfgExtend> {
    public List<StationGroupCfgExtend> equlistByGroup(String sgroupId) {
        return dao.equlistByGroup(sgroupId);
    }

    public List<StationGroupCfgExtend> itemlistById(String sgroupId) {
        return dao.itemlistById(sgroupId);
    }

    public List<StationGroupCfgExtend> graphItemlist(String sgroupId) {
        return dao.graphItemlist(sgroupId);
    }

    List<StationGroupCfgExtend> equlistByEquItemId(String gitemId) {
        return dao.equlistByEquItemId(gitemId);
    }

    public StationGroupCfgExtend getOne(String sgroupId, String groupId, String gitemId) {
        Map map = Maps.newHashMap();
        map.put("sgroupId", sgroupId);
        map.put("groupId", groupId);
        map.put("gitemId", gitemId);
        return dao.getOne(map);
    }
    @Transactional(readOnly = false)
    public void modify(StationGroupCfgExtend sgcfg) {
        dao.modify(sgcfg);
    }

    public List<StationGroupCfgExtend> getListByOfficeId(String id) {
        return dao.getListByOfficeId(id);
    }

    //    表biz_station_equip_grp_cfg中ipPort和model_id都为空的条数
    public int countIpModelNull(String sgroupId) {
        return dao.countIpModelNull(sgroupId);
    }

    public List<HashMap<String, String>> getCfgByStationCode(String stationCode) {
        Map map = Maps.newHashMap();
        map.put("stationCode", stationCode);
        List<HashMap<String, String>> list = dao.getCfgByStationCode(map);
        return list;
    }

    public List<StationGroupCfgExtend> equlistForTransByGroup(String sgroupId) {
        return dao.equlistForTransByGroup(sgroupId);
    }


//    public Map<String, Long> getRegionHashMap() {
//        List<Map<String, Object>> regionMap = regionInfoMapper
//                .getRegionHashMap();
//        Map<String, Long> resultMap = new HashMap<String, Long>();
//        for (Map<String, Object> map : regionMap) {
//            String region = null;
//            Long id = null;
//            for (Map.Entry<String, Object> entry : map.entrySet()) {
//                if ("NAME".equals(entry.getKey())) {
//                    region = (String) entry.getValue();
//                } else if ("ID".equals(entry.getKey())) {
//                    id = ((java.math.BigDecimal) entry.getValue()).longValue();
//                }
//            }
//            resultMap.put(region, id);
//        }
//        return resultMap;
//    }

}
